/**
 * 
 */
var messageId = Ext.util.Cookies.get('messageId');
Ext.util.Cookies.set('messageId', null);
var title, sendername, content, sendtime, attach, attachname;

function init() {
	Ext.Ajax
			.request({
				url : 'messageAction!getById.action?messageId=' + messageId,
				success : function(response) {
					var responseText = response.responseText;
					responseText = Ext.JSON.decode(responseText);
					var message = responseText.message;
					if (message != null) {
						title = message.title;
						sendername = message.sendername;
						content = message.content;
						var sendtime;
						if (message.sendtime != null) {
							var _sendtime = message.sendtime;
							var dates = _sendtime.substr(0, 10).split("-");
							sendtime = new Date(dates[0], dates[1] - 1,
									dates[2], _sendtime.substr(11, 2),
									_sendtime.substr(14, 2));
							sendtime = Ext.util.Format.date(sendtime,
									'Y年m月d日 H:i:s');
						} else {
							sendtime = "尚未发送";
						}
						// if (message.attach != null) {
						// attachname = '<a target="_blank"
						// href="messageAction!down.action?msgid='
						// + message.id
						// + '&fileName='
						// + message.attachname
						// + '">' + message.attachname + '</a>';
						// } else {
						// attachname = "无";
						// }
						Ext.getCmp('mypanel').body
								.update('<div align="left"><font size="3"><b>主题：'
										+ title
										+ '</b></font><br><br><div align="left"><font size="2">发送者：'
										+ sendername
										+ '<br><br>发送时间：'
										+ sendtime
										+ '</font><br><br></div></div>'
										+ '<br><div align="center"><div align="left">内容：'
										+ content + '</div></div>'
								// + '<br><div align="center"><div
								// align="left">附件：'
								// + attachname + '</div></div>'
								);
					}
				},
				failure : function(response) {
					alert("失败!");
				}
			});
}

Ext.onReady(function() {
	Ext.create('Ext.container.Viewport', {
		layout : 'fit',
		items : [ {
			id : 'mypanel',
			autoScroll : true,
			bodyPadding : '10px 60px 10px 60px',
			xtype : 'panel',
			border : false,
			layout : 'fit',
			buttons : [ {
				text : '关闭',
				id : 'closeBtn',
				handler : function() {
					window.top.Utils.activePage("24");
					window.top.Utils.getTabWindow("24");
					window.top.Utils.closePage('messageQuery' + messageId);
				}
			} ],
			buttonAlign : 'center'
		} ]
	});
	init();
});